#include <iostream>
#include <memory>
#include <string>
#include <unistd.h>
#include "EpollServer.hpp"
#include "Err.hpp"

void Usage(std::string proc)
{
    std::cout << "\n\tUsage: \n\t\t" << proc << "\tport\n" << std::endl; 
}

std::string echo(std::string msg)
{
    return "epsvr echo#" + msg;
}

int main(int argc, char* argv[])
{
    if(argc != 2)
    {
        Usage(argv[0]);
        exit(USAGE);
    }

    uint16_t port = atoi(argv[1]);

    std::unique_ptr<epoll_ns::EpollServer> esvr(new epoll_ns::EpollServer(echo, port));

    esvr->initServer();
    esvr->start();

    return 0;
}